package com.listeningframework.boot.autoconfigure.orm.jpa.search.filters;

import com.google.common.collect.Lists;
import com.listeningframework.boot.autoconfigure.orm.jpa.search.Operations;

import java.util.List;

/**
 * 
 * Search Filter
 *
 * @author lixining
 * @version $Id: SearchFilter.java, v 0.1 2016年8月30日 下午4:37:33 lixining Exp $
 */
public abstract class SearchFilter<T extends Comparable<T>> {

    /**
     * Param Name
     */
    protected String     name;
    /**
     * Value
     */
    protected List<T>    value = Lists.newArrayList();
    /**
     * Param Type
     */
    protected Class<T>   type;
    /**
     * Operations
     */
    protected Operations operations;

    /**
     * Getter method for property <tt>value</tt>.
     * 
     * @return property value of value
     */
    public List<T> getValue() {
        return value;
    }

    /**
     * Getter method for property <tt>name</tt>.
     * 
     * @return property value of name
     */
    public String getName() {
        return name;
    }

    /**
     * Setter method for property <tt>name</tt>.
     * 
     * @param name value to be assigned to property name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * Getter method for property <tt>operations</tt>.
     * 
     * @return property value of operations
     */
    public Operations getOperations() {
        return operations;
    }

    /**
     * Setter method for property <tt>operations</tt>.
     * 
     * @param operations value to be assigned to property operations
     */
    public void setOperations(Operations operations) {
        this.operations = operations;
    }

    /**
     * Getter method for property <tt>type</tt>.
     * 
     * @return property value of type
     */
    public abstract Class<T> getType();

    /**
     * Is Special Class
     *
     * @param  cls 目标Class
     * @return Boolean - 是否为指定的类型Class
     */
    public boolean isClass(Class<?> cls) {
        return getType().getName().equals(cls.getName());
    }

}
